<?php

include_once($cfgPaths['lib'].'cms/type/cmsEditType.o.inc.php');

/**
 * Class SimpleViewerGalleryEditType
 *
 * @author Marcel Linnenfelser
 * @package
 * @since 07.01.2010
 * @license XICS License
 */
class SimpleViewerGalleryEditType extends cmsEditType {

 function registerFields () {
   $map[] = $this->name.'title';
   $map[] = $this->name.'gallery';
   $map[] = $this->name.'galleryname';
   $this->map = &$map;
 }

 function render_html () {
    global $cfgPaths,$cfgDeveloperMode,$env;
    $galleryfield = $this->getValue($this->name.'gallery');
    $html  = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'."\n";
    $html .= '  <tr>'."\n";
    $html .= '    <td bgcolor="#000000">'."\n";
    $html .= '      <table border="0" cellspacing="1" cellpadding="3" width="100%">'."\n";
    $html .= '        <tr>'."\n";
    $html .= '          <td width="100" bgcolor="#E0F6FD" valign="top">'."\n";
    $html .= '              <b>'.$this->descr.':</b>'.$this->showFields().'</td>'."\n";
    $html .= '          <td bgcolor="#E0F6FD">'."\n";
    $html .= '  <table border="0">'."\n";
    $html .= '     <tr>'."\n";
    $html .= '      <td>Titel:</td>'."\n";
    $html .= '      <td>'."\n";
    $html .= '        <input tabindex="'.$this->sender->getNextTabindex($this->name.'title').'" name="'.$this->name.'title" value="'.htmlspecialchars($this->getValue($this->name.'title')).'" size="50" maxlength="255"><td>'."\n";
    $html .= '     </tr>'."\n";
    $html .= '     <tr>'."\n";
    $html .= '      <td>Galerie:</td>'."\n";
    $html .= '      <td>'."\n";
    $html .= '<select onchange="$(\''.$this->name.'galleryname\').value=this.options[this.selectedIndex].text" name="'.$this->name.'gallery" tabindex="'.$this->sender->getNextTabindex($this->name.'gallery').'">'."\n";
    m2import(base_ApplicationContext::getInstance()->modPath('simpleViewerGallery').'classes/model/entity/SimpleViewerGalleryEntity.php');
    $entity = new SimpleViewerGalleryEntity(new phpinchains_ActionForm());
    $galleries = $entity->findAll();
    $galleryname = '';
    foreach ($galleries as $gallery){
        $html .= '<option value="'.$gallery['id'].'"';
        if ($gallery['id'] == $galleryfield) {
            $html .= " selected";
            $galleryname = $gallery['svgtitle'];
        }
        $html .= '>'.$gallery['svgtitle'].'</option>';
    }
    if (!$galleryname) $galleryname = $galleries[0]['svgtitle'];
    $html .= '</select></td>'."\n";
    $html .= '     </tr>'."\n";
    $html .= '     <tr>'."\n";
    $html .= '      <td>Gallerietitel:</td>'."\n";
    $html .= '      <td>'."\n";
    $html .= '        <input id="'.$this->name.'galleryname" name="'.$this->name.'galleryname" value="'.htmlspecialchars($this->getValue($this->name.'galleryname')?$this->getValue($this->name.'galleryname'):$galleryname).'" size="50" maxlength="255"><td>'."\n";
    $html .= '     </tr>'."\n";
    $html .= '  </table>'."\n";
    $html .= '        </td></tr>'."\n";
    $html .= '      </table></td>'."\n";
    $html .= '  </tr>'."\n";
    $html .= '</table><br>'."\n";
    return $html;
 }

 function render_javascript () {
 }

}


?>